package leetcode.Y2024M6.review;

import org.junit.Test;

public class S26 {
    public int removeDuplicates(int[] nums) {
        if (nums.length<=1) return 1;
        int left=0;
        int right=1;
        for (; right < nums.length; right++) {
            if (nums[left]!=nums[right]){
                nums[++left]=nums[right];
            }
        }
        return left+1;
    }

    @Test
    public void test() {
        int[] nums={1,1,2};
        int i = removeDuplicates(nums);
        System.out.println(i);
    }

    @Test
    public void test1() {
        int[] nums={0,0,1,1,1,2,2,3,3,4};
        int i = removeDuplicates(nums);
        System.out.println(i);
    }
}
